//////////////////////////////////////////////////////////////////////
////                                                              ////
////  SysGenLoopBack.v                                            ////
////                                                              ////
////                                                              ////
////  This file is part of the "Pico E-12" project                ////
////  http://www.picocomputing.com                                ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
////                                                              ////
//// Copyright (C) 2004, Anzus, INC.                              ////
//// http://www.anzusinc.com                                      ////
////                                                              ////
//// This source file may be used and distributed without         ////
//// restriction provided that this copyright statement is not    ////
//// removed from the file and that any derivative work contains  ////
//// the original copyright notice and the associated disclaimer. ////
////                                                              ////
//// This source file is free software; you can redistribute it   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any   ////
//// later version.                                               ////
////                                                              ////
//// This source is distributed in the hope that it will be       ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// PURPOSE.  See the GNU Lesser General Public License for more ////
//// details.                                                     ////
////                                                              ////
//// You should have received a copy of the GNU Lesser General    ////
//// Public License along with this source; if not, download it   ////
//// from http://www.opencores.org/lgpl.shtml                     ////
////                                                              ////
////////////////////////////////////////////////////////////////////JF
//10/24/2005 - Pico Computing, Heavy Modifications

`include "PicoDefines.v"
//System Generator Test Loopback

module SysGenLoopBack(addr, bank_sel, data_in, data_out, clk, pci_clk, re, we);

input [23:0]addr;
input [7:0]bank_sel;
input [31:0]data_in;
output [31:0]data_out;
input clk;
input pci_clk;
input re;
input we;

reg [31:0]data_out;
wire [9:0]ram_a = addr[9:0];

//--------RAM--------//
reg [31:0]ram[1023:0];
reg [9:0]read_a;

always @(posedge pci_clk) begin
    if (we) ram[ram_a] <= data_in;
    read_a <= ram_a;
end

always @(posedge pci_clk) begin
    if (re) data_out <= ram[read_a];
else
    data_out <= 31'b0;
end
//-------------------//
			
endmodule